<?php

namespace Trawind\Basics\Traits\Transform;


/**
 * Trait ValidationDefaultValue
 * @package Trawind\Basics\Traits\Transform
 */
trait ValidationDefaultValue
{

    /**
     * @param $validator
     */
    public function withValidator($validator)
    {
        $validator->after(function ($validator) {
            if ($defaultValue = static::defaultValue()) {
                $this->merge($defaultValue);
            }
        });
    }


    /**
     * @return array
     */
    public static function defaultValue(): array
    {
        return [];
    }
}
